<script setup lang="ts" name="SystemLoginLogDetail">
import { DICT_TYPE } from '@/enums/dictEnums'
import { formatDate } from '@/utils/dateUtil'
import type { LoginLogType } from '@/api/system/loginLog'

const { t } = useI18n() // 国际化
const visible = ref(false) // 弹窗的是否展示
const detailData = ref({} as LoginLogType) // 详情数据

/** 打开弹窗 */
const open = (data: LoginLogType) => {
  visible.value = true
  detailData.value = data
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗
</script>

<template>
  <Dialog v-model="visible" :title="t('sys.log.sign', 'detail')" width="800px">
    <el-descriptions :column="1" border>
      <el-descriptions-item :label="t('sys.log', 'id')" min-width="120">
        {{ detailData.id }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.log.sign', 'type')">
        <dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_TYPE" :value="detailData.type" />
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.log.sign', 'username')">
        {{ detailData.username }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.log.sign', 'userIp')">
        {{ detailData.userIp }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.log.sign', 'agent')">
        {{ detailData.agent }}
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.log.sign', 'result')">
        <dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_RESULT" :value="detailData.result" />
      </el-descriptions-item>
      <el-descriptions-item :label="t('sys.log.sign', 'createTime')">
        {{ formatDate(detailData.create_time!) }}
      </el-descriptions-item>
    </el-descriptions>
  </Dialog>
</template>

<style scoped lang="scss"></style>
